<?php

namespace App\Dao\System;

use App\Model\System\SystemRoute;
use \Yj\Daos\BaseDao;
use Hyperf\Database\Model\Builder;
use Yj\Daos\Verify;

/**
 * @var SystemRoute
 */
class SystemRouteDao extends BaseDao
{

    public function DaoWhere(array $params)
    {
        return $this->getDaoQuery($params, function (Verify $verify) {
            $verify('id', function (Builder $query, $id) {
                $query->where('id', $id);
            });
            $verify('route', function (Builder $query, $title) {
                $query->where('route', $title);
            });
        });
    }


    public function sync($route, $path, $description, $class_name = '', $method_name = '', $methods = '')
    {
        $methods = json_encode($methods);
        return $this->updateOrCreate(compact('route'), compact('path', 'description', 'class_name', 'methods', 'method_name'));
    }


    public function lists($params)
    {
        return $this->DaoWhere($params)->getList();
    }


}